//验证只能输入数字和小数点
function clearNoNum(obj){
	//先把非数字的都替换掉，除了数字和.
	obj.value = obj.value.replace(/[^\d.]/g,"");
	//必须保证第一个为数字而不是.
	obj.value = obj.value.replace(/^\./g,"");
	//保证只有出现一个.而没有多个.
	obj.value = obj.value.replace(/\.{2,}/g,".");
	//保证.只出现一次，而不能出现两次以上
	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
// 检测是否为合法数据
function isNum(str) {
	return (str.search(/^\d+(\.\d+)?$/) != -1);
}
function trim(str){
    return str.replace(/(^\s*)|(\s*$)/g,"");
  }//去掉空格

  function chekedform() {
  if(document.getElementById("class_attr").value =="")
  {
  
  alert("请选择栏目 ");
	  return;
  }
  
  document.addForm.submit();
}
function seacher(){
	document.indexForm.submit()
	}
	
	function delOneNews(val){
    if(window.confirm('确定要删除吗？ '))
    {
   	  window.location.href='/doTradeReg.do?pkid='+val+'&bpm_id=9243'; 
    } 		
	
}

// 设置二级分类

function setSecondClass(val) {
	
	var up_class_id = val;
	 
	Ti_channelInfo.getChClassByUpId(up_class_id, setSort2);
}

function setSort2(map_data) {
	DWRUtil.removeAllOptions("sort2");
	DWRUtil.addOptions("sort2", {'':"请选择"});
	DWRUtil.addOptions("sort2", map_data);
	$("sort3").style.display = "none";
	var item = $("sort2").length;
	if (item == 0) {
		$("sort2").style.display = "none";
	} else {
		$("sort2").style.display = "inline";
	}
}
// 设置三级分类
function setTherdClass(val) {
	var up_class_id = val;
	Ti_channelInfo.getChClassByUpId(up_class_id, setSort3);
}
function setSort3(map_data) {
  
	if (map_data != null) {
		DWRUtil.removeAllOptions("sort3");
		DWRUtil.addOptions("sort3", {'':"请选择"});
		DWRUtil.addOptions("sort3", map_data);
		var item = $("sort3").length;
		if (item == 0) {
			$("sort3").style.display = "none";
		} else {
			$("sort3").style.display = "inline";
		}
	}
}


function setTypeName1(obj){
	var idx = obj.value;
	$("class_id3").value="";
	$("class_id2").value="";
	$("class_id1").value=idx;
	Ti_channelInfo.getChNameById(idx,setClassName1);
}
function setClassName1(val) {
	$("name3").innerHTML = "";
	$("name2").innerHTML = "";
	$("name1").innerHTML = val;
}

function setTypeName2(obj){
	var idx = obj.value;
	$("class_id3").value="";
	$("class_id2").value=idx;
	Ti_channelInfo.getChNameById(idx,setClassName2);
}

function setClassName2(val) {
	$("name3").innerHTML = "";
	$("name2").innerHTML = "&nbsp; &gt; " + val + "&nbsp;";
}
function setTypeName3(obj){
	var idx = obj.value;
	$("class_id3").value=idx;
	Ti_channelInfo.getChNameById(idx,setClassName3);

	
}
function setClassName3(val) {
	$("name3").innerHTML = "&nbsp; &gt; " + val + "&nbsp;";
}

function ChangeClassStyle(){
	document.getElementById("ch_id").value = "";
	document.getElementById("flag_code").value = "1";
	document.getElementById("classId1").style.display="none";
	document.getElementById("classId2").style.display="block";
}

function formSub()
{
	var str=CKEDITOR.instances.content.getData();
		str=str.replace("<br />","");
   	str=str.replace("<br>","");
   	
    if(trim(str)==""){
    	alert("内容不能为空！");
    	CKEDITOR.instances.content.focus();
			return false;
		}

	if(CKEDITOR.instances.content.getData().length>3010){
		alert("不能大于3000个字符！");
		CKEDITOR.instances.content.focus();
		return false;	
	}
		
		if(document.getElementById('flag_code').value == "0"){
		document.getElementById("ch_id").value = document.getElementById('old_ch_id').value;
	}
	 if(document.getElementById("ch_id").value=="")
	  {

		alert("请选择专题所属栏目！");
			  return;
	  }
	 if(document.getElementById("ch_id").value==""){
	   alert("请选择栏目");
	   return false;
	 }
	document.addForm.submit();
}


